package com.xwj.service.impl;

import com.xwj.dao.StorageMapper;
import com.xwj.service.StorageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author xwj
 * @date 2020/11/10
 */
@Service
@Slf4j
public class StorageServiceImpl implements StorageService {
    @Autowired
    private StorageMapper storageMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean decrease(Long productId, Integer count) {
        log.info("减库存服务开始执行");
        int result = storageMapper.decrease(productId, count);
        log.info("减库存服务结束执行");
        return result > 0;
    }
}
